package wechat.app.util

import java.io.File
import java.io.FileInputStream
import java.util.Properties

class PropertyReader {
//	@Value("${CORPID}")
//    @Accessors String coprid;
//    
//	@Value("${SECRET}")
//    @Accessors String secret;    
//
//	@Value("${AGENTID}")
//  @Accessors String agentid;
	private String confFileName='weixin.properties'
	private Properties prop = null
	new(){
		initProp	
	}
	def getCorpId(){
		 prop.getProperty('CORPID')
	}
	def initProp(){
		 if(prop == null){
			 val filePath =typeof(PropertyReader).getClassLoader().getResource(confFileName).getPath()
			 prop = new Properties();  
	         prop.load(new FileInputStream(new File(filePath)));  
		 }
	}
	def getSECRET(){
		 prop.getProperty('SECRET')
	}	
	def getAGENTID(){
		 prop.getProperty('AGENTID')
	}	
}